
/**
 * finds an array of elements based on elements className.
 */
function getElementsByClassName(/*String*/className, /*String*/filter, /*Element*/start) 
{
    // if we don't have the start element set,
    // we set it to document
    if (start == null)
    {
        start = document;
    }    
        
    var nodes;
    // if the filter is set we can find the nodes
    // by their tagNames.
    if (filter != null) {
        nodes = start.getElementsByTagName(filter)        
    }
    // if the filter is not set, we have to work
    // with all the elements of the start element
    else {
        nodes = start.childNodes();
    }
    
    // now we need to walk throug the array and check
    // for elements className
    var retNodes = new Array();
    for (var index = 0; index < nodes.length; index++) {
        alert(nodes[index].className);
        if (nodes[index].className == className)
        {
            retNodes.push(nodes[index]);
        }
    }
    return retNodes;
}

/**
 * Inserts new element after specified element. 
 */
function insertAfter(/*Element*/ newNode, /*Element*/ refNode)
{
    if (refNode.nextSibling){
        refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
    }
    else {
        refNode.parentNode.appendChild(newNode);
    }
}

